const { src, dest, task, watch, series } = require('gulp');
const eslint = require('gulp-eslint');
const rimraf = require('rimraf');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');

function runClean() {
  return new Promise((resolve) => {
    rimraf('out', () => resolve());
  });
}

function runBuild() {
  return src('src/**/*.ts')
    .pipe(eslint())
    .pipe(tsProject())
    .pipe(dest('out/'));
}

task('clean', runClean);
task('build', series(runClean, runBuild));
